package top.kaoshanji.p3ch11a;

/**
 * 代码清单-p3ch11a-344页a：使用synchronized生成唯一标识符的Java类
 * author kaoshanji
 * ^_^
 * create time 2025/2/3 17:16
 */
public class SynchronizedIdGenerator {

    private int value = 0;

    public synchronized int getNext() {
        return value++;
    }

    public int getNextV2() {
        synchronized (this) {
            return value++;
        }
    }

}
